<%= simple_form_for [:admin, @order], :defaults => { :input_html => { :class => "form-control" } }, remote: true, html: {class: 'form-horizontal' } do |f| %>
  <fieldset>
    <legend><%= title %></legend>
    <%= f.input :name, label: '类型', collection: TerminalOrder::ORDER_NAMES.to_a.collect{|k,v| [v,k]}, checked: @order.name || 'yidong', as: :radio_buttons, item_wrapper_class: 'radio-inline',:input_html => { :class => "" } %>
    <%= f.input :setup_at, label: '安装日期',required: true, as: :ui_date_picker %>
    <%= f.simple_fields_for :terminal do |tf| %>
    <%= f.simple_fields_for :terminal_user do |uf| %>   
      <%= tf.input :mac, label: 'mac地址',required: true  %>
      <%= tf.input :networkcard3g_model, label: '3G网卡型号' %>
      <%= tf.input :imei, label: 'IMEI',required: true  %>
      <%= tf.input :sim_iccid, label: '资费卡ICCID',required: true  %>
      <%= uf.input :user_number, label: '11位用户号码' %> 
      <%= tf.hidden_field :terminal_group_id  %>
      <%= uf.input :name, label: '联系人',required: true %>
      <%= uf.input :landline, label: '固定电话' %>
      <%= uf.input :user_unit, label: '用户单位',required: true %>
      <%= uf.input :phone, label: '联系电话',required: true %>
      <%= uf.input :industry, label: '行业类型', prompt: '请选择',required: true, :input_html => { class: "" } %>
      <%= uf.input :address, label: '地址(加强版)',required: true %>
      <%= uf.input :car_license, label: '车牌号(移动版)',required: true %>
      <%= uf.input :car_unit, label: '车辆所属单位' %>
      <%= uf.input :driver_name, label: '司机姓名',required: true %>
      <%= uf.input :driver_phone, label: '司机联系电话',required: true %>
      <%= uf.input :driver_name2, label: '司机姓名2' %>
      <%= uf.input :driver_phone2, label: '司机联系电话2' %>
    <% end %>
    <% end %>
    <%= f.hidden_field :terminal_group_id  %>
    <%= f.input :worker, label: '工单负责人',required: true  %>
    <%= f.input :worker_phone, label: '工单负责人电话' %>
    <%= f.button :wrapped, value: '提 交', :confirm => "Are you sure?" %>
  </fieldset>
<% end %>
<%= javascript_include_tag "datepicker.js" %>
<% 
  tags = TerminalUser.uniq.pluck('industry').compact
%>
<script type="text/javascript">
  $(function() {

    function update_yidong() {
      $('div.terminal_order_terminal_user_address').hide();
      $('div.terminal_order_terminal_user_user_unit').hide();
      $('div.terminal_order_terminal_user_name').hide();
      $('div.terminal_order_terminal_user_phone').hide();
      $('div.terminal_order_terminal_user_landline').hide();

      $('div.terminal_order_terminal_imei').show();
      $('div.terminal_order_terminal_sim_iccid').show();
      $('div.terminal_order_terminal_user_car_license').show();
      $('div.terminal_order_terminal_user_driver_name').show();
      $('div.terminal_order_terminal_user_driver_name2').show();
      $('div.terminal_order_terminal_user_driver_phone').show();
      $('div.terminal_order_terminal_user_driver_phone2').show();
      $('div.terminal_order_terminal_user_car_unit').show();  
      $('div.terminal_order_terminal_networkcard3g_model').show();    
      $('div.terminal_order_terminal_user_user_number').show();
    }

    function update_zengqiang() {
      $('div.terminal_order_terminal_user_car_license').hide();
      $('div.terminal_order_terminal_imei').hide();
      $('div.terminal_order_terminal_sim_iccid').hide();
      $('div.terminal_order_terminal_networkcard3g_model').hide();
      $('div.terminal_order_terminal_user_user_number').hide();
      $('div.terminal_order_terminal_user_car_license').hide();
      $('div.terminal_order_terminal_user_driver_name').hide();
      $('div.terminal_order_terminal_user_driver_name2').hide();
      $('div.terminal_order_terminal_user_driver_phone').hide();
      $('div.terminal_order_terminal_user_driver_phone2').hide();
      $('div.terminal_order_terminal_user_car_unit').hide();

      $('div.terminal_order_terminal_user_landline').show();
      $('div.terminal_order_terminal_user_address').show();
      $('div.terminal_order_terminal_user_user_unit').show();
      $('div.terminal_order_terminal_user_name').show();
      $('div.terminal_order_terminal_user_phone').show();      
    }

    $("input#terminal_order_name_yidong").click(function() {
      if(this.checked){
        update_yidong();
      }
    });
    $( "input#terminal_order_name_zengqiang").click(function() {
      if(this.checked){
        update_zengqiang();
      }
    });

    <% if @order.name == 'zengqiang' %>
      update_zengqiang();
    <% else %>
      update_yidong();
    <% end %>


  });
</script>
<%= javascript_tag do %>
  $('#terminal_order_terminal_user_attributes_industry').select2({tags:<%= tags.to_s.html_safe %>,  maximumSelectionSize: 1, width: "100%"});
<% end %>
<%= javascript_include_tag "prevent_label.js" %>